//package com.gitee.zydaas.gateway.plugin.sentinel;
//
//import javax.annotation.PostConstruct;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.MediaType;
//import org.springframework.web.reactive.function.BodyInserters;
//import org.springframework.web.reactive.function.server.ServerResponse;
//
//import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
//import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
//import com.gitee.zydaas.common.core.result.ResultCode;
//
///**
// * 自定义网关流控异常
// *
// * @author kinbug
// * @date 2022/7/24
// */
//@Configuration
//public class SentinelConfiguration {
//
//    @PostConstruct
//    private void initBlockHandler() {
//        BlockRequestHandler blockRequestHandler = (exchange, t) ->
//                ServerResponse.status(HttpStatus.TOO_MANY_REQUESTS)
//                        .contentType(MediaType.APPLICATION_JSON)
//                        .body(BodyInserters.fromValue(ResultCode.FLOW_LIMITING.toString())
//                        );
//        GatewayCallbackManager.setBlockHandler(blockRequestHandler);
//    }
//}
